:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7280;
  --line: #e3e7ee;
  --primary: #1f3864;
  --primary-light: #eef2fa;
  --green: #15803d;
  --green-bg: #ecfdf3;
  --red: #b91c1c;
  --red-bg: #fef2f2;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 14px 40px; }

/* --- horní lišta --- */
header.topbar {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; font-size: 17px; color: #fff; }
.topbar .brand small { font-weight: 400; opacity: .75; margin-left: 6px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.topbar nav a {
  color: #dbe4f3; padding: 6px 10px; border-radius: 8px; font-size: 14px;
}
.topbar nav a.active, .topbar nav a:hover {
  background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
}
.company-switch {
  width: auto;
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 14px;
}
.company-switch option { color: var(--text); }

.badge-count {
  background: #ef4444; color: #fff; border-radius: 99px;
  font-size: 11px; padding: 1px 6px; margin-left: 4px; vertical-align: top;
}

/* --- karty --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card h3 { margin: 16px 0 8px; font-size: 15px; }

.grid { display: grid; gap: 12px; }
@media (min-width: 640px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

.stat { text-align: center; padding: 14px 8px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* --- píchačka --- */
.clock-now { font-size: 40px; font-weight: 700; text-align: center; margin: 6px 0 2px; letter-spacing: 1px; }
.clock-date { text-align: center; color: var(--muted); margin-bottom: 14px; }

.punch-status {
  text-align: center; padding: 10px; border-radius: 10px; margin-bottom: 14px;
  font-weight: 600;
}
.punch-status.working { background: var(--green-bg); color: var(--green); }
.punch-status.break { background: var(--amber-bg); color: var(--amber); }
.punch-status.off { background: var(--primary-light); color: var(--primary); }

button, .btn {
  display: inline-block;
  border: 0; border-radius: 10px;
  padding: 12px 18px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}
.btn-big { width: 100%; padding: 18px; font-size: 19px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-light { background: var(--primary-light); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }

form.inline { display: inline; }

/* --- formuláře --- */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary);
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 130px; }
input[type="checkbox"] { width: auto; }

/* --- tabulky --- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr.weekend td { background: #fafbfc; color: var(--muted); }
tr.today td { background: var(--primary-light); }
td.num, th.num { text-align: right; }
.note-cell { white-space: normal; max-width: 260px; }

/* --- štítky --- */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
}
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-gray { background: #eef0f3; color: var(--muted); }

/* --- flash hlášky --- */
.flash {
  margin-top: 14px; padding: 11px 14px; border-radius: 10px; font-weight: 500;
}
.flash-ok { background: var(--green-bg); color: var(--green); }
.flash-warn { background: var(--amber-bg); color: var(--amber); }
.flash-error { background: var(--red-bg); color: var(--red); }

/* --- přepínač měsíců --- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; }
.month-nav .title { font-size: 18px; font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }
.mt { margin-top: 12px; }

details.editbox { margin-top: 4px; }
details.editbox summary { cursor: pointer; color: var(--primary); font-size: 13px; }
details.editbox .card { margin-top: 8px; }

/* Editační panel v tabulce: na mobilu jako overlay přes celou obrazovku,
   jinak by roztáhl tabulku do šířky a nedalo se s ním pracovat. */
.editbox-close { display: none; }
@media (max-width: 700px) {
  details.editbox[open]:has(> .card)::before {
    content: "";
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 55;
  }
  details.editbox[open] > .card {
    position: fixed;
    left: 8px; right: 8px; top: 60px;
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    z-index: 60;
    margin-top: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    white-space: normal;
  }
  .editbox-close {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    background: var(--primary-light);
    color: var(--primary);
  }
}

/* --- login --- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; padding: 0 14px; }
.login-logo { text-align: center; font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 18px; }

.password-reveal {
  background: var(--amber-bg); border: 1px dashed var(--amber);
  padding: 12px; border-radius: 10px; margin-top: 12px;
}
.password-reveal code { font-size: 18px; font-weight: 700; }

@media print {
  header.topbar, .no-print, button, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}
