@import url("https://fonts.googleapis.com/css?family=DM+Sans:400,500,700&display=swap");

:root {
  --bg-page: #f3f6fd;
  --surface: #ffffff;
  --surface-muted: #fafcff;
  --text-main: #1f1c2e;
  --text-muted: #4A4A4A;
  --border-soft: #e9ebf0;
  --shadow-soft: 0 12px 36px rgba(136, 148, 171, 0.15);
  --accent-error: #df3670;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-primary: #1f1c2e;
}

.dark:root {
  --bg-page: #0a0e17;
  --surface: #1f2937;
  --surface-muted: #243244;
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --border-soft: rgba(255, 255, 255, 0.1);
  --shadow-soft: 0 12px 36px rgba(0, 0, 0, 0.4);
  --accent-error: #ff6b6b;
  --accent-primary: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

p, span, div { margin: 0; }
.text-title { font-size: 20px; font-weight: 700; }
.text-timer { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; z-index: 2; position: relative; }
.text-section { font-size: 14px; font-weight: 700; opacity: 0.8; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.text-body { font-size: 14px; font-weight: 500; }
.text-small { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.app {
  width: 100%;
  max-width: 1280px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-page);
  overflow: hidden;
}

/* Login Screen */
.login-app {
  width: 100%; max-width: 420px; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--surface); border-radius: 28px; padding: 40px 32px; width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.12); border: 1px solid var(--border-soft);
}
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-logo svg { width: 32px; height: 32px; color: var(--text-main); }
.login-app .field-error { margin-top: 4px; }

.sidebar {
  position: fixed;
  bottom: 0; width: 100%;
  display: flex; justify-content: space-around;
  padding: 12px 16px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
  z-index: 20;
  transition: background 0.3s ease;
}
.dark .sidebar { background: rgba(31, 41, 55, 0.85); }

.brand-logo { display: none; }

.nav-item {
  background: transparent; border: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); cursor: pointer;
  padding: 8px 16px; border-radius: 12px; transition: all 0.2s; font-family: inherit;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-text { font-size: 10px; font-weight: 600; margin-top: 2px; }
.nav-item.active { background: var(--surface-muted); color: var(--text-main); box-shadow: var(--shadow-soft); }

.admin-nav-item { display: none; }
body.is-admin .admin-nav-item { display: flex; }

.back-to-employee-item { color: var(--text-main); }
.sidebar-divider { display: none; }

.main-content {
  flex: 1; overflow-y: auto; padding-bottom: 90px;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 24px; position: sticky; top: 0; z-index: 10;
  background: rgba(243, 246, 253, 0.85); backdrop-filter: blur(10px);
}
.dark .topbar { background: rgba(10, 14, 23, 0.85); }
.topbar-actions { display: flex; gap: 12px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-soft); border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center; color: var(--text-main); cursor: pointer; transition: 0.15s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 18px; height: 18px; }

.screen { display: none; padding: 20px 24px 24px; flex: 1; flex-direction: column; }
.screen.active { display: flex; }
.content-wrapper { width: 100%; max-width: 860px; margin: 0 auto; }

.admin-screen { display: none; padding: 32px 24px; flex: 1; overflow-y: auto; }
.admin-screen.active { display: block; }

.status-card {
  border-radius: 24px; padding: 32px 24px; text-align: center; margin-bottom: 24px; box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; align-items: center; transition: background 0.4s ease;
}
.status-card .text-timer, .status-card .text-small, .status-card .text-body { color: #1f1c2e !important; }
.state-waiting { background: #d5deff; }
.state-active { background: #c8f7dc; }
.state-break { background: #fee4cb; }
.state-break-overrun { background: #ffc4c4; border: 2px solid var(--accent-error); }
.state-done { background: #e9e7fd; }

.timer-wrapper {
  position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; margin: 16px 0;
}
.timer-wrapper svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.progress-bg { stroke: rgba(31, 28, 46, 0.1); stroke-width: 6; fill: none; }
.progress-ring { stroke: #1f1c2e; stroke-width: 6; fill: none; stroke-linecap: round; stroke-dasharray: 339.29; stroke-dashoffset: 339.29; transition: stroke-dashoffset 1s linear; }

.actions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 32px; }
.action-btn {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 16px; box-shadow: var(--shadow-soft);
  padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text-main); font-family: inherit; cursor: pointer; transition: 0.2s;
}
.action-btn svg { width: 22px; height: 22px; opacity: 0.8; }
.action-btn:hover { background: var(--surface-muted); }
.action-btn:active { transform: scale(0.95); }
.action-btn:disabled { opacity: 0.4; pointer-events: none; box-shadow: none; }

.list-row, .log-row {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 16px 0; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background 0.2s, padding 0.2s;
}
.log-row .left { display: flex; align-items: center; gap: 16px; }
.list-row:hover, .log-row:hover { background-color: var(--surface); border-radius: 12px; padding-left: 12px; border-bottom-color: transparent; box-shadow: var(--shadow-soft); }
.list-row.flag .list-title, .list-row.flag .text-body { color: var(--accent-error); }
.icon-wrap { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-muted); border: 1px solid var(--border-soft); color: var(--text-main); display: flex; align-items: center; justify-content: center; }
.icon-wrap svg { width: 18px; height: 18px; }

.note-item { background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 12px; border: 1px solid var(--border-soft); box-shadow: var(--shadow-soft); }
.note-tag { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; }
.detail-summary { background: var(--surface); border-radius: 20px; padding: 24px; text-align: center; margin-bottom: 24px; border: 1px solid var(--border-soft); box-shadow: var(--shadow-soft); }
.detail-summary .total { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.detail-flag { display: flex; align-items: center; gap: 8px; background: #ffd3e2; color: #1f1c2e; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 600; margin-bottom: 12px; box-shadow: var(--shadow-soft); }

.notice-card { border-radius: 16px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-soft); }
.notice-warning { background: #fee4cb; }
.notice-warning p { color: #1f1c2e !important; }
.notice-neutral { background: #dbf6fd; }
.notice-neutral p { color: #1f1c2e !important; }

.back-btn {
  width: 100%; padding: 16px; border-radius: 16px; border: 1px solid var(--border-soft); background: var(--surface); box-shadow: var(--shadow-soft);
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-main);
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 24px; cursor: pointer; transition: 0.15s;
}
.back-btn:active { transform: scale(0.96); }
.admin-screen .back-btn { width: auto; padding: 12px 20px; display: inline-flex; }

.profile-header { display: flex; flex-direction: column; align-items: center; padding: 20px 0 32px; }
.avatar { width: 80px; height: 80px; border-radius: 50%; background: #d5deff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 24px; color: #1f1c2e; margin-bottom: 16px; box-shadow: 0 8px 16px rgba(0,0,0,0.1); background-size: cover; background-position: center; }

.avatar-wrap { position: relative; display: inline-block; margin-bottom: 16px; }
.profile-header .avatar-wrap { margin-bottom: 16px; }
.profile-header .avatar-wrap .avatar { margin-bottom: 0; }
.avatar-edit-btn {
  position: absolute; bottom: 0; right: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--text-main); color: var(--surface); border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-soft);
  padding: 0; transition: 0.15s;
}
.avatar-edit-btn svg { width: 15px; height: 15px; }
.avatar-edit-btn:active { transform: scale(0.9); }
.avatar-edit-btn-sm { width: 26px; height: 26px; }
.avatar-edit-btn-sm svg { width: 12px; height: 12px; }

.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); z-index: 100; align-items: flex-end; justify-content: center;
}
.overlay.open { display: flex; }
.sheet { width: 100%; background: var(--surface); border-radius: 32px 32px 0 0; padding: 32px; position: relative; animation: slideUp 0.3s ease; box-shadow: 0 -10px 40px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;}
.drag-handle { width: 48px; height: 5px; border-radius: 3px; background: var(--border-soft); margin: 0 auto 24px; }
.modal { background: var(--surface); border-radius: 24px; padding: 32px; width: 100%; max-width: 500px; box-shadow: 0 24px 48px rgba(0,0,0,0.2); animation: popIn 0.2s ease; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes popIn { 0% { transform: scale(0.95); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.reason-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 12px; }
.sheet-actions { display: flex; gap: 12px; margin-top: 24px; }
.sheet-btn { border-radius: 16px; padding: 16px; font-family: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--border-soft); background: var(--surface); color: var(--text-main); cursor: pointer; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: 0.15s; }
.sheet-btn.selected { border-color: #0F766E; background: #c8f7dc; color: #1f1c2e; }
.sheet-btn.primary { background: var(--text-main); color: var(--surface); border-color: var(--text-main); flex-direction: row; justify-content: center; }
.sheet-btn:disabled { opacity: 0.4; pointer-events: none; }
.note-field { width: 100%; min-height: 100px; margin-top: 16px; border: 1px solid var(--border-soft); border-radius: 16px; padding: 16px; font-family: inherit; font-size: 14px; background: var(--surface-muted); color: var(--text-main); resize: none; outline: none; }
.field-error { display: none; font-size: 12px; color: var(--accent-error); margin-top: 8px; font-weight: 600; }
.field-error.show { display: block; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-bottom: 32px; }
.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }

.summary-card {
  background: var(--surface); padding: 20px; border-radius: 20px; box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft); display: flex; flex-direction: column;
}
.summary-card .number { font-size: 32px; font-weight: 700; margin-bottom: 4px; }

.emp-card {
  border-radius: 24px; padding: 24px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-soft);
  display: flex; flex-direction: column; transition: transform 0.2s;
}
.emp-card:hover { transform: translateY(-4px); }
.emp-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.emp-avatar { width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,0.08); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #1f1c2e; font-size: 16px; background-size: cover; background-position: center; }
.emp-time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: #1f1c2e; margin: 16px 0 8px; }
.emp-card .text-body, .emp-card .text-small { color: #1f1c2e !important; }

.overrun-badge { background: var(--accent-error); color: white !important; font-size: 11px; font-weight: 700; padding: 6px 10px; border-radius: 12px; display: inline-flex; align-items: center; gap: 4px; }

.timeline-box { background: var(--surface); border-radius: 24px; padding: 28px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-soft); margin-bottom: 24px; position: relative;}

.form-group { margin-bottom: 20px; width: 100%; }
.input-field {
  width: 100%; padding: 16px; border-radius: 16px; border: 1px solid var(--border-soft); background: var(--surface-muted);
  color: var(--text-main); font-family: inherit; font-size: 15px; outline: none; transition: border 0.2s;
}
.input-field:focus { border-color: var(--accent-primary); }

.btn-primary { padding: 16px 32px; border-radius: 16px; background: var(--text-main); color: var(--surface); font-weight: 700; border: none; cursor: pointer; font-family: inherit; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: 0.15s; }
.btn-secondary { padding: 12px 24px; border-radius: 12px; background: var(--surface-muted); color: var(--text-main); font-weight: 700; border: 1px solid var(--border-soft); cursor: pointer; font-family: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; transition: 0.15s; }
.btn-primary:active, .btn-secondary:active { transform: scale(0.96); }

.filter-bar {
  display: flex; gap: 16px; margin-bottom: 24px; align-items: center; background: var(--surface);
  padding: 12px; border-radius: 20px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-soft);
}
.filter-bar .input-field { padding: 12px 16px; margin: 0; border: none; background: transparent; }
.filter-divider { width: 1px; height: 32px; background: var(--border-soft); }

.report-mode-tabs {
  display: inline-flex; gap: 4px; background: var(--surface); padding: 4px;
  border-radius: 14px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-soft);
  margin-bottom: 20px;
}
.mode-tab {
  border: none; background: transparent; color: var(--text-muted); font-family: inherit;
  font-weight: 700; font-size: 14px; padding: 10px 20px; border-radius: 10px; cursor: pointer; transition: 0.15s;
}
.mode-tab.active { background: var(--text-main); color: var(--surface); }

.note-box { background: var(--bg-page); border-radius: 12px; padding: 16px; margin-top: 16px; border-left: 4px solid var(--text-muted); }
.audit-log { background: #fee4cb; color: #1f1c2e; padding: 16px; border-radius: 12px; font-size: 13px; margin-top: 24px; font-weight: 600; display: flex; gap: 12px; align-items: flex-start;}

.two-col { display: grid; grid-template-columns: 1fr; gap: 20px; }

.settings-holiday { order: -1; }

.checkbox-group { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.check-label { display: flex; align-items: center; gap: 8px; background: var(--surface-muted); padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border-soft); cursor: pointer; font-size: 14px; font-weight: 500; }
.check-label input { width: 18px; height: 18px; accent-color: var(--text-main); }

@media (min-width: 768px) {
  body { padding: 24px; }

  .app {
    flex-direction: row;
    height: calc(100vh - 48px);
    border-radius: 32px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 24px 64px rgba(0,0,0,0.1);
  }

  .sidebar {
    position: relative; width: 100px; height: 100%; flex-direction: column; justify-content: flex-start; align-items: center;
    padding: 32px 12px; background: var(--surface); border-top: none; border-right: 1px solid var(--border-soft); box-shadow: var(--shadow-soft); z-index: 10;
  }
  .brand-logo { display: flex; flex-direction: column; align-items: center; padding: 0 0 40px; }
  .brand-logo svg { width: 36px; height: 36px; color: var(--text-main); }
  .brand-logo .text-title { display: none; }

  .nav-item { padding: 16px 0; width: 100%; margin-bottom: 12px; border-radius: 20px; }
  .nav-item svg { width: 24px; height: 24px; }
  .nav-text { display: none; }

  .main-content { padding-bottom: 0; background: var(--bg-page); }

  .topbar { background: rgba(243, 246, 253, 0.85); border-bottom: 1px solid var(--border-soft); }
  .dark .topbar { background: rgba(10, 14, 23, 0.85); }

  .status-card { flex-direction: row; justify-content: space-around; text-align: left; padding: 40px; }
  .actions-grid { display: flex; justify-content: center; gap: 24px; }
  .action-btn { flex-direction: row; width: 220px; padding: 20px; justify-content: center;}
  .action-btn svg { margin-right: 12px; }

  .overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 500px; border-radius: 24px; animation: popIn 0.3s ease; }
  .drag-handle { display: none; }

  .admin-sidebar { width: 260px; align-items: stretch; padding: 32px 20px; }
  .admin-sidebar .brand-logo { flex-direction: row; padding: 0 12px 32px; justify-content: flex-start; gap: 12px; }
  .admin-sidebar .brand-logo .text-title { display: block; }
  .admin-sidebar .nav-item { flex-direction: row; justify-content: flex-start; gap: 16px; padding: 14px 16px; }
  .admin-sidebar .nav-text { display: block; font-size: 14px; margin-top: 0; }
  .admin-sidebar .sidebar-divider { display: block; height: 1px; background: var(--border-soft); margin: 8px 4px 16px; }

  .admin-screen { padding: 32px 40px; }

  .two-col { grid-template-columns: 1fr 1fr; gap: 24px; }
  .settings-holiday { order: 0; }
}